
package com.epam.android.training.app.services;

import com.epam.android.training.app.R;
import com.epam.android.training.app.activities.TestListActivity;

import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

/**
 * new tests reciever.
 * 
 * @author Natallia_Kukharchyk
 */
public class NewTestReciever extends BroadcastReceiver {

  private static final int TEST_ID = 1;

  @Override
  public void onReceive(Context context, Intent intent) {
    NotificationManager notificationManager = (NotificationManager) context
        .getSystemService(Context.NOTIFICATION_SERVICE);
    // simply use one of default images
    int icon = android.R.drawable.presence_online;
    CharSequence tickerText = context.getString(R.string.alert_ticker_title);
    long when = System.currentTimeMillis();
    Notification notification = new Notification(icon, tickerText, when);
    Intent notificationIntent = new Intent(context, TestListActivity.class);
    notificationIntent.putExtra(TestListActivity.ONLY_NEW, true);
    PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0);
    notification.setLatestEventInfo(context, context.getString(R.string.alert_title),
        context.getString(R.string.alert_description), contentIntent);

    notificationManager.notify(TEST_ID, notification);

  }

}
